<div class="main-wrap">

    <div class="crumb-wrap">
         <div class="crumb-list"><i class="icon-font">&#xe06b;</i><span class="crumb-name">注意：导出Excel只导出最近1000条数据</span></div>
    </div>
    <div class="search-wrap">
        <div class="search-content">
            <form action="" method="post">
                <table class="search-tab">
                    <tr>
                        <th width="70">商品级别:</th>
                        <td>
                            {:frm_out_put($sortarr,'sort','option',$query['sort'],'','-请选择-')}
                        </td>
                        <th width="70">分类:</th>
                        <td>
                            {:frm_out_put($categray,'cate','option',$query['cate'],'','-请选择-')}
                        </td>
                        <if condition="$isAdmin eq true">
                            <th width="70">物流：</th>
                            <td>{:frm_out_put($express,'exp','option',$query['exp'],'','-请选择-')}</td>
                        </if>
                        <th width="70">每页显示:</th>
                        <td>
                            <php>$psize = array(20=>'20',50=>'50',100=>'100');</php>
                            {:frm_out_put($psize,'psize','option',$query['psize'],'')}
                        </td>
                        <th width="70">姓名:</th>
                        <td><input type="text" name="receive_name" value="{$query['receive_name']}" ></td>
                        <td><input class="btn btn-primary btn2" value="查询" type="submit"></td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
    <div class="result-wrap">
        
             <div class="result-title">
                <div class="result-list">
                    <a href="{:U('Admin/Prize/export',array('parameters'=>json_encode($query)))}"><i class="icon-font">&#xe005;</i>导出Excel</a>
                    <a href="#" onclick="printArea();return false;" ><i class="icon-font">&#xe005;</i>打印</a>
                </div>
            </div>

            <div class="result-content">
                <table class="result-tab" width="100%" id="printarea">
                    <tr>
                        <th class="tc1 noprint" width="5%"><input class="allChoose" name="" type="checkbox"></th>
                        <!--<th>ID</th>-->
                        <th>姓名</th>
                        <th>联系电话</th>
                        <th>收货地址</th>
                        <th>商品码</th>
                        <th>商品级别</th>
                        <th>分类</th>
                        <th>备注</th>
                        <th width="10%">提交时间</th>
                        <th>状态</th>
                        <th width="10%" class="noprint">单号</th>
                        <th class="noprint">操作</th>
                    </tr>
                    <volist id="vo" name="list">
                    <tr>
                        <td class="tc noprint"><input name="id[]" type="checkbox" value="{$vo.id}"></td>
                        <!--<td>{$vo.id}</td>-->
                        <td>{$vo.username}</td>
                        <td>{$vo.phone}</td>
                        <td><php>echo str_replace(' ','',$vo['area']) . $vo['address']</php></td>
                        <td>{$vo.sncode}</td>
                        <td>{$sortarr[$vo['sort']]}</td>
                        <td>{$categray[$vo['categray']]}</td>
                        <td>{$vo.remark}</td>
                        <td>{:date('Y-m-d H:i:s',$vo['create_time'])}</td>
                        <if condition="$vo['status'] gt 0">
                            <td>
                                <span class='blue'>已配送</span><br>
                                <if condition="$vo['kd_id'] gt 0">
                                    <span>已分配给:{$express[$vo['kd_id']]}</span>
                                </if>
                            </td>
                            <td class="noprint">{$vo.kdcode}</td>
                            <td class="noprint"></td>
                        <else/>
                            <td>
                                <span class='red'>待配送</span><br>
                                <if condition="$vo['kd_id'] gt 0">
                                    <span>已分配给:{$express[$vo['kd_id']]}</span>
                                </if>
                            </td>
                            <td class="noprint"><input type="text" name="kdcode"/></td>
                            <td class="noprint"><a class="pointer" _href="{:U('Admin/Prize/send')}" data-id="{$vo.id}" onclick='sendGoods(this)'>配送</a></td>
                        </if>

                        <!--<td>
                            <php>
                            if($vo['status']){
                                echo "<span class='blue'>已发放</span>";
                            }else{
                                echo "<span class='red'>未发放</span>";
                            }
                            </php>
                        </td>
                        <td><input type="text"/></td>
                        <td>
                            <php>
                            if($vo['status']){
                                echo "<a href='' onclick='sendGoods();return false'></a>";
                            }else{
                                echo "<a href='".U('Admin/Prize/send',array('id'=>$vo[id]))."' onclick='sendGoods(this)'>配送</a>";
                            }    
                            </php>
                        </td>-->
                        
                    </tr>
                    </volist>
                </table>
                <div class="list-page"> {$page}</div>

                <if condition="$isAdmin eq true">
                    <if condition="$opt eq 1">
                        <table class="result-tab" width="100%">
                            <tr><td width="10%">选择配送物流：</td><td>{:frm_out_put($express,'kdtype','radio')}<a class="btn btn-primary fr" onclick="selKD()">派发</a></td></tr>
                        </table>
                    </if>
                    <if condition="$opt eq 2">
                        <table class="result-tab" width="100%">
                            <tr><td width="10%">操作：</td><td>{:frm_out_put($option_bal,'opt_bal','radio')}<a class="btn btn-primary fr" onclick="selBal()">提交</a></td></tr>
                        </table>
                    </if>

                </if>
            </div>

    </div>

</div>
<script language="javascript" type="text/javascript" src="__JS__/jquery.jqprint-0.3.js"></script>
<!--<script language="javascript" type="text/javascript" src="__JS__/lodopfuncs.js"></script>-->
<script type="text/javascript">
    function sendGoods(obj){
        var p = $(obj).parent().parent();
        var _href = $(obj).attr('_href'),
            id = $(obj).attr('data-id'),
            kdcode = p.find('input[name=kdcode]').val();
        if($.trim(kdcode)==''){
            alert('请填写快递单号');return;
        }
        $.post(_href,{id:id,kdcode:kdcode},function(data){
            if(data.status == 200){
                alert(data.msg);
                location.reload();
            }else{
                alert(data.msg);
            }
        },'json');
    }

    var selkd_url = "{:U('Admin/Prize/selectKd')}";
    var selbal_url = "{:U('Admin/Prize/selectBal')}";
    function selKD(){
        var ids = [];
        var kdtype = $('input[name=kdtype]:checked').val();
        $('.tc').find('input[type=checkbox]').each(function(idx,e){
            if($(e).attr('checked')){
                ids.push(parseInt($(e).val()));
            }
        });
        if(ids.length == 0){
            alert('您尚未选择任务记录');
        }else{
            var ids_str = JSON.stringify(ids);
            $.post(selkd_url,{ids:ids_str,kdtype:kdtype},function(data){
                if(data.status==200){
                    alert(data.msg);
                    location.reload();
                }else{
                    alert(data.msg);
                }
            },'json');
        }
    }

    function selBal(){
        var ids = [];
        var opt_bal = $('input[name=opt_bal]:checked').val();
        $('.tc').find('input[type=checkbox]').each(function(idx,e){
            if($(e).attr('checked')){
                ids.push(parseInt($(e).val()));
            }
        });
        if(ids.length == 0){
            alert('您尚未选择任务记录');
        }else{
            var ids_str = JSON.stringify(ids);
            $.post(selbal_url,{ids:ids_str,opt_bal:opt_bal},function(data){
                if(data.status==200){
                    alert(data.msg);
                    location.reload();
                }else{
                    alert(data.msg);
                }
            },'json');
        }
    }
    function printArea(){
        $("#printarea").jqprint();
    }
    /*var LODOP;
    function myPreview(){

        LODOP=getLodop();
        LODOP.PRINT_INIT("打印控件功能演示_Lodop功能_全页排除按钮");
        var strBodyStyle="<style>.noprint{display: none;}</style>";
        //strBodyStyle=strBodyStyle+"<style>"+document.getElementById("style1").innerHTML+"</style>";
        var strBodyHtml=strBodyStyle+"<body>"+document.getElementById("printarea").innerHTML+"</body>";
        LODOP.ADD_PRINT_HTM(20,"10%","80%",900,strBodyHtml);
        LODOP.PREVIEW();
    };*/
</script>